Moved some code over