bit of reordering and cleanup
bit of cleanup and reordering