javascript code cleanup