cleaning up js with more functions