Refactored instance methods into global
Fixed refactored code and zero division bug