#9 added signature, #2 changed logic