fixed some of the issues @ngokevin mentioned