refactored prototype to more reasonable format