improved register

simplified register, added if statement