Revamp for cleaner code