Reverted to previous working code