adjusted js code for more mobile functionality