refactored a bit, now cleaner