cleaning up code and clearing errors