Dunno why I didn't use exceptions for this...