moved some code arround