fix undefined method
refactor