Cleaned up code and catching imps more efficient