code rearranged
fixes