Subroutines sample modified for better clarity