added and modified some helper functions