addressed issues from deprecation of attr in jQuery now using prop
made additional minor changes.