Removed debugs, refactored some logic to method