moved code to a class