Adding some helper functions and re-organize according to object class