#56 rearrange the code a bit