Cleaned up unlock code