Improve magic number check