pep_051 solved (but ugly)