added checker for z beginning and end