Updating jquery layout
Fixed function refactoring (extract function)