Minor changes to logic