Minor refactoring in read function
Added check for missing input