Small logic error and magic number