Moved some code to new file for consistency