Fixed div

Fixed the missing div and organised some code. Not tested