Added more code to distinguish cases