Creating DOM Elements with jQuery. Fixed some logical errors