all codes are moved to jquery function