Fixing Alex's ugly code ;)