[#14] changed repeated code