prevent magic number and a little bug fixed