workng moved some code around for  looking better