Moved some code arround