improved comments and added defined constants for readability