you use magic number '8' too much in your code. It's better to replace it by const variable.