fixed some repeating issues
moved the jQuery outside loop and tested to work on different options