clean up code and fix the record feature!