Removed print statements and cleaned up functionality