made extra button javascript function code cleaner