This is crazy unreadable, please refactor