move function to method