modified js for responsive behaviour