Added code for elif - needs testing!!!