Replace magic number and refactoring