some cleanup on the code