refactored market price calc