code cleanup and added popup binding