Reorganized code and added scale method