got generic functions to work; might not be any better than switch statements however