This will explode on bad input, should probably wrap in a try-except