scaling logic
however there are performance issues