cleaned up some functions