Address potential bugs in the code