cleaned up code for new functions