fixed box and hover code to  combine code

repositored code to reduce lines