Moved some code back in