Removed unused vars
Refactored handling to allow for user calls