more cleaned up code