refactore again
put function in class