fixed switch to disable morgan
moved some code out