Cleaned up the code and took out regex