simplify some functions and make them work with vector