much nicer code :)