Update: better names, cleaner code