Added structs and optimized