Cleaned up code to add pieces