fixed undefined issues