moved some code