prototype refactored