too complicated for me to break up the codes.

will try to understand asap