Better separation for javascript code