finalised.

cleaned up and optimised js