added code to fix warnings and enhance readability