added more functionality cleaned up js