prototype and messy range scaling added
range scaling refactored